<%-- 
    Document   : viewCustomer
    Created on : Jan 1, 2010, 4:46:10 PM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<form method="post">
    <table border="1">
        <tr>
            <td>Name:</td>
            <td>${customer.name}</td>
        </tr>
        <tr>
            <td>Personal Id:</td>
            <td>${customer.personalId}</td>
        </tr>

        <tr>
            <td>Cellphone:</td>
            <td>${customer.cellphone}</td>
        </tr>
    </table>
    <table border="1">
        <tr><th colspan="4">Purchase history</th></tr>
        <tr><th>#</th><th>Invoice #</th><th>Date</th><th>Total</th></tr>
        <c:set var="total" value="0"/>
        <c:forEach var="invoice" items="${invoices}" varStatus="counter">
            <c:set var="total" value="${total+invoice.totalPrice}"/>
            <tr><td>${counter.count}</td><td><a href="<%=request.getContextPath()%>/sales/printInvoice?uid=${invoice.autoId}">${invoice.number}</a></td><td><fmt:formatDate value="${invoice.createdDate}" pattern="MMM d, yyyy"/></td><td>${invoice.totalPrice}</td></tr>
        </c:forEach>
        <tr><td>${counter.count}</td><td colspan="2">Over all total</td><td>${total}</td></tr>
    </table>
</form>